var usetimer = true;
var timeout = null;
var globalQuizInfo = null;

function sendFormToServer(email, content, starttime, endtime, right, wrong, tried, total, score) {
	document.getElementById("email").value = email;
	document.getElementById("content").value = content;
	document.getElementById("starttime").value = starttime;
	document.getElementById("endtime").value = endtime;
	document.getElementById("score").value = score;
	document.getElementById("right").value = right;
	document.getElementById("wrong").value = wrong;
	document.getElementById("tried").value = tried;
	document.getElementById("total").value = total;
	document.getElementById("blsForm").submit();
	//TODO: fuer jeden entry ein getelement.
}


function callNextFunc() {
	if (timeout != null) {
		clearTimeout(timeout);
	}
	globalQuizInfo.timerFunc();
}


function jQuizMeStatusCallback(quizInfo, curQuiz) {
	if (usetimer) {
		if (timeout != null) {
			clearTimeout(timeout);
		}
	}

//	alert(JSON.stringify(quizInfo));
//	alert(quizInfo.nextFunc);

	if (quizInfo.hasQuit) {
		// TODO call sendFormToServer
		sendFormToServer(email, content, starttime, endtime, score, tried, total, right, wrong);
	} else {
		if (usetimer) {
			globalQuizInfo = quizInfo;
			timeout = setTimeout("callNextFunc()", 6000);
		}
	}
}
